# 自动收集所有.cpp和.h文件（递归子目录）
file(GLOB_RECURSE SOURCES "*.cpp" "*.c")
file(GLOB_RECURSE HEADERS "*.h" "*.hpp")



add_executable(MainApp ${SOURCES} ${HEADERS})

# 添加公共头文件路径
target_include_directories(MainApp PUBLIC
    ${CMAKE_CURRENT_BINARY_DIR}/include
    ${CMAKE_CURRENT_BINARY_DIR}/
    ${CMAKE_SOURCE_DIR}/config # 访问根目录生成的Config.h
    )

# target_link_libraries(MainApp PRIVATE app_module)





target_link_libraries(MainApp PUBLIC rs485_module)
target_link_libraries(MainApp PUBLIC agile_modbus_module)
target_link_libraries(MainApp PRIVATE yj_common_module)
target_link_libraries(MainApp PRIVATE mqtt_module)
target_link_libraries(MainApp PRIVATE sensor_module)

# 显式链接线程库
target_link_libraries(MainApp PUBLIC Threads::Threads)
# 若需要进一步传递 -lrt 给依赖此库的可执行文件
target_link_options(MainApp PUBLIC -lrt)


# 查找libgoogle-glog库
find_library(GLOG_LIBRARY NAMES glog)

if(NOT GLOG_LIBRARY)
    message(FATAL_ERROR "glog library not found. Please install libgoogle-glog-dev package")
endif()

# 链接libgoogle-glog库
target_link_libraries(MainApp
    PRIVATE
    ${GLOG_LIBRARY}
)
